package me.ymfs.springboot.guice.configuration;

import com.google.inject.Guice;
import com.google.inject.Injector;
import me.ymfs.springboot.guice.service.AppModule;
import me.ymfs.springboot.guice.service.order.OrderService;
import me.ymfs.springboot.guice.service.user.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GuiceConfiguration {

    @Bean
    public Injector injector(ApplicationContext context) {
        return Guice.createInjector(new AppModule(context));
    }

    @Bean
    public UserService userService(Injector injector) {
        return injector.getInstance(UserService.class);
    }

    @Bean
    public OrderService orderService(Injector injector) {
        return injector.getInstance(OrderService.class);
    }

}
